const http = require("axios")
const qs = require('querystring')

let axios = http.create({
    baseURL: 'http://192.168.1.5:8090',
    timeout: 10000,
    headers: {'Content-Type': 'application/x-www-form-urlencoded'},
    transformRequest: [function (data) {
        data = qs.stringify(data)
        return data
    }]
})
module.exports = {
    getProductList (pageSize, pageNumber, productSearchKey) {
        return axios.get('/good/get', {
            params: {
                pageSize: pageSize,
                pageNumber: pageNumber,
                key: productSearchKey
            }
        })
    },


    getProductById(id){
      return axios.get('/good/getDetailInfo', {
        params: {
          goodId: id
        }
      })
    },

    orderProduct(id){
      return axios.get('/good/orderGood', {
        params: {
          goodId: id
        }
      })
    }



    // refreshProductList(pageSize, pageNumber, productSearchKey){
    //     return this.getProductList(pageSize, pageNumber, productSearchKey).then(response => {
	   //      console.log("refresh products=",response.data.data.list)
	   //      this.$store.commit('updateProducts', response.data.data.list)
    //     }).catch(error => {
	   //      console.log(error)
    //     })
    // },
    // getNextPageProduct(pageSize, pageNumber, productSearchKey){
	   //  return this.getProductList(pageSize, pageNumber, productSearchKey).then(response => {
		 //    console.log("next page products=",response.data.data.list)
		 //    this.$store.commit('updateNextPageProducts', response.data.data.list)
	   //  }).catch(error => {
		 //    console.log(error)
	   //  })
    // }



}